package com.hx.setting.entity;

import com.hx.setting.entity.Entity;
import com.hx.setting.model.RoleModel.ParentroleEnum;
import java.io.Serializable;
import java.util.Date;
import org.json.JSONObject;

/**
 * Generate Date : 2014-03-16
 * Generate Version : v3.0
 * Generate Name : Honey v3.1 Test
 * Generate User : THINK
 * JDK Version : 1.5
 */
public class RoleEntity extends AbstractEntity implements Serializable, Entity
{

	/** 类序列化版本标识 */
	private static final long	serialVersionUID	= 4404018268564715412L;

	/** id */
	private Long				id;

	/** 角色名称 */
	private String				rolename;

	/** 父角色继承(id:id:id) */
	private ParentroleEnum		parentrole;

	/** 角色继承深度 */
	private Integer				depth;

	/** 是否允许角色继承 */
	private Short				allowassignedrecordsto;

	/** 
	 * 默认构造函数
	 */
	public RoleEntity()
	{
		super();
	}

	/** 
	 * 带参数构造函数
	 */
	public RoleEntity(Long id/*id */, String rolename/*角色名称 */, ParentroleEnum parentrole/*父角色继承(id:id:id)*/, Integer depth/*角色继承深度 */, Short allowassignedrecordsto/*是否允许角色继承 */)
	{
		this.setId( id );//id 
		this.setRolename( rolename );//角色名称 
		this.setParentrole( parentrole );//父角色继承(id:id:id)
		this.setDepth( depth );//角色继承深度 
		this.setAllowassignedrecordsto( allowassignedrecordsto );//是否允许角色继承
	}

	/** 
	 * 获取id
	 * @return id
	 */
	@Override
	public final Long getId()
	{
		return this.id;
	}

	/** 
	 * 设定id
	 * @param id
	 * @return 返回自身
	 */
	public final RoleEntity setId(Long id)
	{
		this.id = id;
		return this;
	}

	/** 
	 * 获取角色名称
	 * @return 角色名称
	 */
	public final String getRolename()
	{
		return this.rolename;
	}

	/** 
	 * 设定角色名称
	 * @param rolename
	 * @return 返回自身
	 */
	public final RoleEntity setRolename(String rolename)
	{
		this.rolename = rolename;
		if ( this.rolename != null && this.rolename.length() == 0 ) this.rolename = null;
		return this;
	}

	/** 
	 * 获取父角色继承(id:id:id)
	 * @return 父角色继承(id:id:id)
	 */
	public final ParentroleEnum getParentrole()
	{
		return this.parentrole;
	}

	/** 
	 * 设定父角色继承(id:id:id)
	 * @param parentrole
	 * @return 返回自身
	 */
	public final RoleEntity setParentrole(ParentroleEnum parentrole)
	{
		this.parentrole = parentrole;
		return this;
	}

	/** 
	 * 获取角色继承深度
	 * @return 角色继承深度
	 */
	public final Integer getDepth()
	{
		return this.depth;
	}

	/** 
	 * 设定角色继承深度
	 * @param depth
	 * @return 返回自身
	 */
	public final RoleEntity setDepth(Integer depth)
	{
		this.depth = depth;
		return this;
	}

	/** 
	 * 获取是否允许角色继承
	 * @return 是否允许角色继承
	 */
	public final Short getAllowassignedrecordsto()
	{
		return this.allowassignedrecordsto;
	}

	/** 
	 * 设定是否允许角色继承
	 * @param allowassignedrecordsto
	 * @return 返回自身
	 */
	public final RoleEntity setAllowassignedrecordsto(Short allowassignedrecordsto)
	{
		this.allowassignedrecordsto = allowassignedrecordsto;
		return this;
	}

	@Override
	public int hashCode()
	{
		int answer = -1;
		String solt = "&tkn)";//随机盐
		answer = new StringBuilder()
				.append( "RoleEntity" )
				.append( this.id )
				.append( this.rolename )
				.append( this.parentrole )
				.append( this.depth )
				.append( this.allowassignedrecordsto )
				.append( solt )
				.toString()
				.hashCode();
		return answer;
	}

	@Override
	public String toString()
	{
		return new StringBuilder()
				.append( "RoleEntity : [" )
				.append( "    id : " )
				.append( this.id )
				.append( "    rolename : " )
				.append( this.rolename )
				.append( "    parentrole : " )
				.append( this.parentrole )
				.append( "    depth : " )
				.append( this.depth )
				.append( "    allowassignedrecordsto : " )
				.append( this.allowassignedrecordsto )
				.append( "]\n" )
				.toString();
	}

	public JSONObject toJsonObject()
	{
		JSONObject answer = new JSONObject();
		answer.put( "id" ,id == null ? "" : id );
		answer.put( "rolename" ,rolename == null ? "" : rolename );
		answer.put( "parentrole" ,parentrole == null ? "" : parentrole );
		answer.put( "depth" ,depth == null ? "" : depth );
		answer.put( "allowassignedrecordsto" ,allowassignedrecordsto == null ? "" : allowassignedrecordsto );
		return answer;
	}

	public String toXml()
	{
		StringBuilder answer = new StringBuilder();
		answer.append( "<item>\n" );
		answer.append( "  <id>" ).append( id == null ? "" : id ).append( "</id>\n" );
		answer.append( "  <rolename>" ).append( rolename == null ? "" : rolename ).append( "</rolename>\n" );
		answer.append( "  <parentrole>" ).append( parentrole == null ? "" : parentrole ).append( "</parentrole>\n" );
		answer.append( "  <depth>" ).append( depth == null ? "" : depth ).append( "</depth>\n" );
		answer.append( "  <allowassignedrecordsto>" ).append( allowassignedrecordsto == null ? "" : allowassignedrecordsto ).append( "</allowassignedrecordsto>\n" );
		answer.append( "</item>\n" );
		return answer.toString();
	}
}
/* Honey v3.1 Test - version:3 - OriginalChecksum:Bb0d643866870a2a2a4a8164a1a2bb1e7 (do not edit this line) */
